package com.nbsaas.boot.evaluate.rest.convert;

import com.nbsaas.boot.entity.evaluate.EvaluateReply;
import com.nbsaas.boot.evaluate.api.domain.simple.EvaluateReplySimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 评价回复-列表对象转换器
*/

public class EvaluateReplySimpleConvert implements Converter<EvaluateReplySimple, EvaluateReply> {




@Override
public EvaluateReplySimple convert(EvaluateReply source) {
    EvaluateReplySimple result = new EvaluateReplySimple();

                if(source.getReplyType()!=null){
                   Map<Integer,String> ReplyTypeMap=new HashMap<>();
                       ReplyTypeMap.put(1,"商家回复");
                       ReplyTypeMap.put(2,"用户追评");
                       ReplyTypeMap.put(3,"用户回复");
                       ReplyTypeMap.put(4,"系统回复");
                   String label=  ReplyTypeMap.get(source.getReplyType());
                   result.setReplyTypeName(label);
                }
                result.setReplyType(source.getReplyType());
                result.setImages(source.getImages());

               try {
                   if(source.getParentReply()!=null){
                       result.setParentReply(source.getParentReply().getId());
                   }
                } catch (Exception ignored) { }

                result.setLevel(source.getLevel());

                try {
                    if(source.getReplyUser()!=null){
                        result.setReplyUserName(source.getReplyUser().getName());
                    }
                } catch (Exception ignored) { }

                result.setIpAddress(source.getIpAddress());
                result.setLikeCount(source.getLikeCount());
                result.setUserAgent(source.getUserAgent());
                result.setReplyPath(source.getReplyPath());
                result.setAddDate(source.getAddDate());
                result.setContent(source.getContent());

                try {
                    if(source.getTargetUser()!=null){
                        result.setTargetUserName(source.getTargetUser().getName());
                    }
                } catch (Exception ignored) { }


               try {
                   if(source.getReplyUser()!=null){
                       result.setReplyUser(source.getReplyUser().getId());
                   }
                } catch (Exception ignored) { }

                result.setAuditNote(source.getAuditNote());
                if(source.getAnonymous()!=null){
                   Map<Integer,String> AnonymousMap=new HashMap<>();
                       AnonymousMap.put(0,"否");
                       AnonymousMap.put(1,"是");
                   String label=  AnonymousMap.get(source.getAnonymous());
                   result.setAnonymousName(label);
                }
                result.setAnonymous(source.getAnonymous());
                if(source.getStoreState()!=null){
                    result.setStoreStateName(String.valueOf(source.getStoreState()));
                }
                result.setStoreState(source.getStoreState());
                result.setId(source.getId());

               try {
                   if(source.getEvaluate()!=null){
                       result.setEvaluate(source.getEvaluate().getId());
                   }
                } catch (Exception ignored) { }


               try {
                   if(source.getTargetUser()!=null){
                       result.setTargetUser(source.getTargetUser().getId());
                   }
                } catch (Exception ignored) { }

                result.setLastDate(source.getLastDate());


    return result;
}

}